#!/usr/bin/env python

import nltk
# from __future__ import division

# ------------part A
# def unusual_words(text):
# 	text_vocab = set(w.lower() for w in text if w.isalpha())
# 	en_vocab = set(w.lower() for w in nltk.corpus.words.words())
# 	unusual = text_vocab - en_vocab
# 	return sorted(unusual)

# foo = unusual_words(nltk.corpus.gutenberg.words('austen-sense.txt'))
# print foo[:10]
# foo = unusual_words(nltk.corpus.nps_chat.words())
# print foo[:10]


# ------------part B
# def content_fraction(text):
# 	stopwords = nltk.corpus.stopwords.words('english')
# 	content = [w for w in text if w.lower() not in stopwords]
# 	return len(content)*100 / len(text)

# foo = content_fraction(nltk.corpus.reuters.words())
# print foo


# ------------part C
puzzle_letters = nltk.FreqDist('egivrvonl')
wordlist = nltk.corpus.words.words()
obligatory = 'r'
foo=[]
for w in wordlist:
	if len(w) >= 6 and obligatory in w and nltk.FreqDist(w) <= puzzle_letters:
		foo.append(w);
print foo;
# [w for w in wordlist if len(w) >= 6 
# 	and obligatory in w
# 	and nltk.FreqDist(w) <= puzzle_letters]
